#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    bool strongPasswordCheckerII(string password) {
        if (password.size() < 8)
            return false;
        int small = 0, big = 0, num = 0, nb = 0;
        string s1("!@#$%^&*()-+");
        for (int i = 0; i < password.size(); i++)
        {
            if (i != 0 && password[i] == password[i - 1])
                return false;
            if (!small)
                small = (password[i] >= 97 && password[i] <= 122) ? 1 : 0;
            if (!big)
                big = (password[i] >= 65 && password[i] <= 90) ? 1 : 0;
            if (!num)
                num = (password[i] >= 48 && password[i] <= 57) ? 1 : 0;
            if (!nb)
            {
                for (auto& e : s1)
                {
                    if (password[i] == e)
                    {
                        nb = 1;
                        break;
                    }
                }
            }
        }

        return (small == 1 && small == big && big == num && num == nb) ? true : false;
    }
};